const app = getApp();
var config = app.globalData.config;
const http = require('../../utils/http.js');
Page({
	data: {
		monthTime: "", //月
		dayTime: "", //月
		weekTime: "", //星期
		msgCount: 0, //消息数量
		todayList: [], //今日课程数据
		myList: [], //我的课程数据

	},
	onReady() {
		if (!app.login()) {
			return;
		}
	},
	onLoad(options) {
		this.getNowTime();
		this.getMsgCount(); //获取消息总数
		this.getTodayCourse();
		this.getMyCourse();
	},
	getNowTime() { //获取当前时间
		var _month = new Date().getMonth() + 1;
		var _day = new Date().getDate();

		var show_day = new Array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
		var date = new Date();
		date.setDate(date.getDate());
		var dayFun = date.getDay();
		var _weekTime = show_day[dayFun];

		this.setData({
			monthTime: _month,
			dayTime: _day,
			weekTime: _weekTime
		});
	},
	getMsgCount() { //获取消息总数
		var that = this;
		http.httpPost(config.getMessageCount, {}, function(e) {
			// console.log(e);
			that.setData({
				'msgCount': e.data
			});
		});
	},
	getTodayCourse() { //获取今日课程
		var that = this;
		http.httpPost(config.getTodayCourse, {
      is_curriculum:true
    }, function(e) {
			that.setData({
				'todayList': e.data
			});
		});
	},
	getMyCourse() { //获取我的课程
		var that = this;
		http.httpPost(config.getMyCourse, {}, function(e) {
			// console.log(e);
			that.setData({
				'myList': e.data
			});
		});

	},
	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {

	}
})
